<!DOCTYPE html>
<!-- ng-app -->
<html lang="en" ng-app="app">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="../../../js/plugins/angular/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-controller="cont">
        <div class="show">
            服务返回的值：
            <!-- 这里的写法跟以往的不同 -->
            <span>{{info('name')}}</span>
            <span>{{info('sex')}}</span>
            <span>{{info('score')}}</span>
        </div>
    </div>

    <script>
        angular.module('app',[],function ($provide) {
            $provide.factory('$output',function () {
                var stu = {
                    name:'张三',
                    sex:'男',
                    score:'60'
                };
                return stu;
            })
        }).controller('cont',function ($scope,$output) {
                $scope.info = function (n) {
                    for(_n in $output){
                        if(_n == n){
                            return ($output[_n]);
                        }
                    }
                }
            });

    </script>
</body>
</html>